package com.turing.post.account.util;

import java.io.Serializable;
import java.math.BigInteger;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;

import com.turing.post.util.PCPSUtil;

/**
 * 子帐户销售员列表
 * 
 * @author ys
 * @date 2012-12-17
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "SalesGroup")
@IdClass(SalesGroup.class)
public class SalesGroup implements Serializable {
	public SalesGroup() {
		super();
	}

	/**
	 * 销售员组ID
	 */
	private BigInteger salesGroupId;
	/**
	 * 销售员ID
	 */
	private BigInteger salesId;
	/**
	 * 贡献度
	 */
	private BigInteger degreeOfcontribution;
	/**
	 * 本组散列值
	 */
	private BigInteger salesGroupHash;

	@Id
	@Column(name = "SALESGROUPID", nullable = false)
	public BigInteger getSalesGroupId() {
		return this.salesGroupId;
	}

	public void setSalesGroupId(BigInteger salesGroupId) {
		this.salesGroupId = salesGroupId;
	}

	@Id
	@Column(name = "SALESID", nullable = false)
	public BigInteger getSalesId() {
		return this.salesId;
	}

	public void setSalesId(BigInteger salesId) {
		this.salesId = salesId;
	}

	@Column(name = "DEGREEOFCONTRIBUTION", nullable = false)
	public BigInteger getDegreeOfcontribution() {
		return this.degreeOfcontribution;
	}

	public void setDegreeOfcontribution(BigInteger degreeOfcontribution) {
		this.degreeOfcontribution = degreeOfcontribution;
	}

	@Column(name = "SALESGROUPHASH", nullable = false)
	public BigInteger getSalesGroupHash() {
		return this.salesGroupHash;
	}

	public void setSalesGroupHash(BigInteger SalesGroupHash) {
		this.salesGroupHash = SalesGroupHash;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;

		result = prime
				* result
				+ ((this.getSalesGroupId() == null) ? 0 : this
						.getSalesGroupId().hashCode());
		result = prime
				* result
				+ ((this.getSalesId() == null) ? 0 : this.getSalesId()
						.hashCode());

		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof SalesGroup))
			return false;

		SalesGroup other = (SalesGroup) obj;

		if (!PCPSUtil.compareObject(this.getSalesGroupId(), other
				.getSalesGroupId()))
			return false;

		return PCPSUtil.compareObject(this.getSalesId(), other.getSalesId());
	}
}
